﻿using Newtonsoft.Json;

namespace DataServer.ApplicationLib.Rules
{
    public class ProcedureRuleContent
    {
        public string? RuleName { get; set; }

        public string? ProcedureName { get; set; }
    }

    public class ProcedureRuleVerifyFactory
    {
        public static IRuleVerify? CreateVerify(CreateRuleVerifyInput input)
        {
            IRuleVerify? ruleVerify = null;

            if (!string.IsNullOrEmpty(input.RuleContent))
            {
                var content = JsonConvert.DeserializeObject<ProcedureRuleContent>(input.RuleContent);
                if (content != null)
                {

                    content.RuleName = input.RuleName;
                    switch (input.CheckWay)
                    {
                        case DataCheckWay.InDB:
                            ruleVerify = new DbProcedureVerify(content);
                            break;
                        default:
                            break;
                    }

                }
            }
            return ruleVerify;
        }
    }

    internal class DbProcedureVerify : RuleVerifyBase<ProcedureRuleContent>, IRuleVerify
    {
        public DbProcedureVerify(ProcedureRuleContent ruleContent) : base(ruleContent)
        {
        }

        public VerifyRuleResult Verify(RuleContext ruleContext)
        {
            throw new System.NotImplementedException();
        }
    }
}
